import { defineStore } from "pinia";
export const Tabs = defineStore("Tabs", {
  state: () => {
    return {
      TabsList: [
        {
          name: "home",
          meta: {
            title: "主页",
          },
          closable: false,
          path:"/home"
        },
      ],
    };
  },
  actions: {
    SetTabsList(list: any) {
      const hasSameArray = this.TabsList.some(
        user => user.name === list.name
      );

      if (!hasSameArray) {
        list.closable = true,
        this.TabsList.push(list);
      }
    },
    DeleteTabsList(name:any){
        this.TabsList = this.TabsList.filter(user => user.name !== name);
        const tab = this.TabsList[this.TabsList.length-1]
        return{
            tab : tab.path
        }
    },
    TpTabs(index:any){
        const tp = this.TabsList[index]
        return{
            tp: tp.path
        }
    }
  },
});

export const govTabs = defineStore("Tabs", {
  state: () => {
    return {
      TabsList: [
        {
          name: "govhome",
          meta: {
            title: "主页",
          },
          closable: false,
          path:"/govhome"
        },
      ],
    };
  },
  actions: {
    SetTabsList(list: any) {
      const hasSameArray = this.TabsList.some(
        user => user.name === list.name
      );

      if (!hasSameArray) {
        list.closable = true,
        this.TabsList.push(list);
      }
    },
    DeleteTabsList(name:any){
        this.TabsList = this.TabsList.filter(user => user.name !== name);
        const tab = this.TabsList[this.TabsList.length-1]
        return{
            tab : tab.path
        }
    },
    TpTabs(index:any){
        const tp = this.TabsList[index]
        return{
            tp: tp.path
        }
    }
  },
});